package com.baiku.sanhos.response;

import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class ResultVO {

    private int code;
    private String msg;
    private Object data;

    public ResultVO(Object data){
        this.code=StatusCode.SUCCESS.getCode();
        this.msg=StatusCode.SUCCESS.getMsg();
        this.data=data;
    }
    public ResultVO(int code,String msg){
        this.code=code;
        this.msg=msg;
    }
    public ResultVO(StatusCode statusCode){
        this.code=statusCode.getCode();
        this.msg=statusCode.getMsg();
    }
    public ResultVO(StatusCode statusCode,Object data){
        this(statusCode);
        this.data=data;
    }
    public ResultVO(Integer code,String msg, Object data){
        this.code = code;
        this.data = data;
        this.msg=msg;
    }


    public static ResultVO ok(Object data){
        ResultVO resultVO = new ResultVO(StatusCode.SUCCESS,data);
        return resultVO;
    }
    public static ResultVO ok(StatusCode statusCode){
        return new ResultVO(statusCode);
    }
    public static ResultVO ok(){
        return new ResultVO(StatusCode.SUCCESS,null);
    }

    public static ResultVO error(Object data){
        ResultVO resultVO = new ResultVO(StatusCode.SCHEDULING_EXISTS,data);
        return resultVO;
    }
    public static ResultVO error(StatusCode statusCode){
        return new ResultVO(statusCode);
    }
    public static ResultVO fail(Object data){
        ResultVO resultVO = new ResultVO(StatusCode.FAIL_LOGIN,data);
        return resultVO;
    }
    public static ResultVO fail(){
        return fail(null);
    }

}
